import { defineStore } from "pinia";
import { userLogin } from "@/api/user";
import request from "@/utils/http";
import permissionToken from "@/utils/permissionToken";

export const authStore = defineStore("auth", {
  state() {
    return {
      loading: false,
    };
  },
  actions: {
    async login(params: any) {
      this.loading = true;
      const res = await userLogin(params);
      console.log("789", res);

      localStorage.setItem("authInfo", JSON.stringify(res));
      this.loading = false;
      permissionToken();

      return res;
    },
  },
});
